<!DOCTYPE html>
<html lang="cmn-Hans" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>无限小说网</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
</head>
<body>
<div class="layui-container">
    <form class="layui-form" action="" onsubmit="">
        <div class="layui-form-item">
            <label class="layui-form-label">关键词</label>
            <div class="layui-input-block">
                <input type="text" name="key" required  lay-verify="required" placeholder="请输入查询关键词" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">查询范围</label>
            <div class="layui-input-block">
                <select name="searchType" lay-verify="required">
                    <option value="0">小说名称</option>
                    <option value="1">小说简介</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

    <div class="layui-row">
        <div class="layui-col-md3" th:each="it:${genresList}" style="padding: 15px;">
            <a th:href="@{'/genres/'+${it.id}+'/10/1'}" th:text="${it.name}"></a>
        </div>
        <div class="layui-col-md3" style="padding: 15px;">
            <a th:href="@{/genres/0/10/1}" th:text="全部"></a>
        </div>
    </div>
</div>

<script th:src="@{/layui/layui.js}"></script>
<script>
    layui.define(function () {
        const form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            location.href="[[@{/search/}]]"+data.field.key+"/"+data.field.searchType+"/10/1"
            layer.msg(data.field.key);
            return false;
        });
    });
</script>
</body>
</html>